package com.hzyb.oldpack.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hzyb.oldpack.dao.JdbcDao;
import com.hzyb.oldpack.service.ShopCategorieService;
import com.mysql.jdbc.StringUtils;
@Service
public class ShopCategorieServiceImpl implements ShopCategorieService{

	@Resource
	private JdbcDao JdbcDao;

	@Override
	public List<Map<String, Object>> getShopCategories() {
		// TODO Auto-generated method stub
		return JdbcDao.getShopCategories();
	}

	@Override
	public List<Map<String, Object>> getItemInformation(String categories_sid) {
		List<Map<String, Object>> list=new ArrayList<>();
		if(StringUtils.isNullOrEmpty(categories_sid)) {
			list=JdbcDao.getAllCategories();
		}else {
			return JdbcDao.getitemInformation(categories_sid);
		}
		List<Map<String, Object>> returnList=new ArrayList<>();
		for(Map<String, Object> map:list) {
			Map<String, Object> result=new HashMap<>();
			result.put("text", map.get("categories_name"));
			result.put("categories_sid", map.get("categories_sid"));
			result.put("detail", JdbcDao.getitemInformation(map.get("categories_sid").toString()));
			returnList.add(result);
		}
		return returnList;
	}

}
